home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / messages.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  4.4 KB  |  132 lines

  1. #ifndef __MESSAGES_CC
  2. #define __MESSAGES_CC
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * messages.cc - Definitions for the Standard Library messaging facet
  8.  *
  9.  *
  10.  ***************************************************************************
  11.  *
  12.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  13.  * ALL RIGHTS RESERVED *
  14.  * The software and information contained herein are proprietary to, and
  15.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  16.  * intends to preserve as trade secrets such software and information.
  17.  * This software is furnished pursuant to a written license agreement and
  18.  * may be used, copied, transmitted, and stored only in accordance with
  19.  * the terms of such license and with the inclusion of the above copyright
  20.  * notice.  This software and information or any other copies thereof may
  21.  * not be provided or otherwise made available to any other person.
  22.  *
  23.  * Notwithstanding any other lease or license that may pertain to, or
  24.  * accompany the delivery of, this computer software and information, the
  25.  * rights of the Government regarding its use, reproduction and disclosure
  26.  * are as set forth in Section 52.227-19 of the FARS Computer
  27.  * Software-Restricted Rights clause.
  28.  * 
  29.  * Use, duplication, or disclosure by the Government is subject to
  30.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  31.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  32.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  33.  * P.O. Box 2328, Corvallis, Oregon 97339.
  34.  *
  35.  * This computer software and information is distributed with "restricted
  36.  * rights."  Use, duplication or disclosure is subject to restrictions as
  37.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  38.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  39.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  40.  * then the "Alternate III" clause applies.
  41.  *
  42.  **************************************************************************/
  43.  
  44. #ifndef _RWSTD_NO_NAMESPACE
  45. namespace std {
  46. #endif
  47.  
  48. // ---------------------------------------
  49. // Facet messages<charT> member templates.
  50. // ---------------------------------------
  51.  
  52. template <class charT>
  53. locale::id messages<charT>::id;
  54.  
  55. template <class charT>
  56. messages<charT>::messages (size_t refs):
  57.     locale::facet(refs,locale::messages), __RWSTD::messages_impl("C")
  58. { }
  59.  
  60. template <class charT>
  61. messages<charT>::messages (size_t refs,string name):
  62.     locale::facet(refs,locale::messages), __RWSTD::messages_impl(name)
  63. { }
  64.  
  65. template <class charT>
  66. messages<charT>::~messages() { }
  67.  
  68. template <class charT>
  69. messages_base::catalog
  70. messages<charT>::do_open (const string &cat_name,const locale &loc) const
  71. {
  72.   return open_cat_(cat_name,loc);
  73. }
  74.  
  75. template <class charT>
  76. _TYPENAME messages<charT>::string_type
  77. messages<charT>::do_get (messages_base::catalog cat,
  78.     int set,int msgid,const string_type &dflt) const
  79. {
  80.   char *text=get_mess_(cat,set,msgid);
  81.  
  82.   // The following is wrong -- it should be using codecvt instead of
  83.   // ctype.widen, but this requires an effective codecvt implementation ...
  84.  
  85.   if (text) {
  86. #ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
  87.     return use_facet<ctype<charT> >(get_loc_(cat)).widen(string(text));
  88. #else
  89.     return use_facet(get_loc_(cat),(ctype<charT>*)0).widen(string(text));
  90. #endif
  91.   }
  92.   return dflt;
  93. }
  94.  
  95. // Specialize member function for char for performance.  (Is this really okay
  96. // without specializing the whole class?  Borland fails on it -- if it is in
  97. // fact legit, we need a config test.)
  98.  
  99. #if 0
  100. string messages<char>::do_get
  101.     (messages_base::catalog cat,int set,int msgid,const string &dflt) const
  102. {
  103.   char *text=get_mess_(cat,set,msgid);
  104.   if (text)
  105.     return text;
  106.   return dflt;
  107. }
  108. #endif
  109.  
  110. template <class charT>
  111. void messages<charT>::do_close (messages_base::catalog cat) const
  112. {
  113.   close_cat_(cat);
  114. }
  115.  
  116.  
  117. // ----------------------------------------------------------
  118. // Messages by-name member templates: messages_byname<charT>.
  119. // ----------------------------------------------------------
  120.  
  121. template <class charT>
  122. messages_byname<charT>::messages_byname (const char *name, size_t refs):
  123.     messages<charT>(refs,get_loc_name_(name))
  124. { }
  125.  
  126. #ifndef _RWSTD_NO_NAMESPACE
  127. } // namespace std
  128. #endif
  129.  
  130. #pragma option pop
  131. #endif /* __MESSAGES_CC */
  132.